package services.dbf;

import com.linuxense.javadbf.*;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author sergiu.marin
 * @since 15.01.2014
 */
public class Service {


    public static void main(String args[]) {
        String path = "D:\\db\\vama.dbf";
        try {
            InputStream inputStream = new FileInputStream(path);
            DBFReader reader = new DBFReader(inputStream);

            int numberOfFields = reader.getFieldCount();

            for (int i = 0; i < numberOfFields; i++) {

                DBFField field = reader.getField(i);

                System.out.println(field.getName());
            }

            // Now, lets us start reading the rows
            //
            Object[] rowObjects;

           /* while ((rowObjects = reader.nextRecord()) != null) {

                for (int i = 0; i < rowObjects.length; i++) {

                    System.out.println(rowObjects[i]);
                }
            }*/

            // By now, we have itereated through all of the rows

            inputStream.close();
        } catch (IOException e) {

            System.out.println(e.getMessage());
        }
    }
}